using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using DIS_DAL_WS.Models;

namespace DIS_DAL_WS.DTO
{
    [DataContract]
	public class ChemistWareHouseDTO
	{
        [DataMember]
		public int ID { get; set; }
        [DataMember]
		public string Name { get; set; }
        [DataMember]
		public string Phone { get; set; }
        [DataMember]
		public string Address { get; set; }
        [DataMember]
        public List<OrdersDTO> Orders { get; set; }
        [DataMember]
        public List<EmployeeDTO> Employees { get; set; }
        [DataMember]
        public List<DailyReportDTO> DailyReports { get; set; }
        [DataMember]
        public List<WeeklyReportDTO> WeeklyReports { get; set; }

        public static ChemistWareHouseDTO Translate(ChemistWareHouse Entity)
        {
            if (Entity != null)
            {
                var dto = new ChemistWareHouseDTO
                {
                    ID = Entity.ID,
                    Name = Entity.Name,
                    Phone = Entity.Phone,
                    Address = Entity.Address,
                    Orders = new List<OrdersDTO>(),
                    Employees = new List<EmployeeDTO>(),
                    DailyReports = new List<DailyReportDTO>(),
                    WeeklyReports = new List<WeeklyReportDTO>()
                };
                if (Entity.Orders != null)
                {
                    foreach (var item in Entity.Orders)
                    {
                        dto.Orders.Add(OrdersDTO.Translate(item));
                    }
                }
                if (Entity.Employee != null)
                {
                    foreach (var item in Entity.Employee)
                    {
                        dto.Employees.Add(EmployeeDTO.Translate(item));
                    }
                }
                if (Entity.DailyReport != null)
                {
                    foreach (var item in Entity.DailyReport)
                    {
                        dto.DailyReports.Add(DailyReportDTO.Translate(item));
                    }
                }
                if (Entity.WeeklyReport != null)
                {
                    foreach (var item in Entity.WeeklyReport)
                    {
                        dto.WeeklyReports.Add(WeeklyReportDTO.Translate(item));
                    }
                }
                return dto;
            }
            return null;
        }

        public static ChemistWareHouseDTO TranslateBase(ChemistWareHouse Entity)
        {
            if (Entity != null)
            {
                var dto = new ChemistWareHouseDTO
                {
                    ID = Entity.ID,
                    Name = Entity.Name,
                    Phone = Entity.Phone,
                    Address = Entity.Address
                };
                return dto;
            }
            return null;
        }

        public static ChemistWareHouse Reverse(ChemistWareHouseDTO obj)
        {
            var entity = new ChemistWareHouse
            {
                ID = obj.ID,
                Name = obj.Name,
                Phone = obj.Phone,
                Address = obj.Address
            };
            return entity;
        }

        public void UpdateEntity(ref ChemistWareHouse entity)
        {
            entity.Name = Name;
            entity.Phone = Phone;
            entity.Address = Address;
        }
	}
}